// MyFamily - XML based genealogy program.
// Copyright (C) 2006  Doug Swisher
// See the file COPYING.txt for license details.

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

using DataModel;


namespace WebLib
{
    class FileNameBuilder
    {
        // TODO - Doug - 8/2/2006 - give the user the option to choose .htm or .html as the extension
        private const string extension = ".htm";

        public enum Page
        {
            HomePage,
            IndividualIndex,
            SourceIndex
        }

        private DirectoryInfo directoryInfo;

        public FileNameBuilder(DirectoryInfo dir)
        {
            this.directoryInfo = dir;
        }


        public FileInfo GetPageName(Page page)
        {
            switch (page)
            {
                case Page.HomePage:
                    return GetPageName("default");

                case Page.IndividualIndex:
                    return GetPageName("individuals");

                case Page.SourceIndex:
                    return GetPageName("sources");

                default:
                    throw new ApplicationException(string.Format("Unhandled page type '{0}' in GetPageName", page));
            }
        }


        public FileInfo GetPageName(string name)
        {
            return new FileInfo(Path.Combine(directoryInfo.FullName, name + extension));
        }


        public FileInfo GetPageName(FamilyIndividual indi)
        {
            return GetPageName("indi_" + indi.Id);
        }


        public FileInfo GetPageName(FamilySource source)
        {
            return GetPageName("source_" + source.Id);
        }

    }
}
